#include<iostream>
using namespace std;
class TreeNode {
public:
	int Data;
	TreeNode* left;
	TreeNode* right;
	string str;
	TreeNode(int n = 0) {
		Data = n;
		left = right = NULL;
	}
};
TreeNode* made(TreeNode* p1, TreeNode* p2) {
	TreeNode* p = new TreeNode(p1->Data + p2->Data);
	if (p1->Data > p2->Data) {
		p->left = p2;
		p->right = p1;
	}
	else {
		p->left = p1;
		p->right = p2;
	}
	return p;
}
void Sort_Tree(TreeNode** a, int n) {
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			if (a[i]->Data < a[j]->Data) {
				TreeNode* p = a[i];
				a[i] = a[j];
				a[j] = p;
			}
		}
	}
}
void print(TreeNode* p,string cur) {
	if (p == NULL) {
		return;
	}
	if (p->left == NULL && p->right == NULL) {
		p->str = cur;
	}
	print(p->left, cur + '0');
	print(p->right, cur + '1');

}
int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		int n;
		cin >> n;
		int n1 = n;
		TreeNode** p = new TreeNode * [n];
		for (int j = 0; j < n; j++) {
			int m;
			cin >> m;
			p[j] = new TreeNode(m);
		}
		Sort_Tree(p, n);
		TreeNode** p1 = new TreeNode * [n];
		for (int j = 0; j < n; j++) {
			p1[j] = p[j];
		}
		while (n > 1) {
			TreeNode* tmp = made(p[n - 1], p[n - 2]);
			p[n - 2] = tmp;
			n--;
			Sort_Tree(p, n);
		}
		print(p[0], "");
		for (int j = 0; j < n1; j++) {
			cout << p1[j]->Data << '-' << p1[j]->str << endl;
		}
	}
	return 0;
}